package com.inspectortime.service.expire;

import java.util.Date;

import com.inspectortime.domain.Inspection;

/**
 * Expires inspections if the time between now and the inspection time is less than a limit
 * @author mKvalsvik
 *
 */
public class TimeBeforeExpirationStrategy implements ExpirationStrategy {

	private int timeLimitInHours = 24;
	
	public void setTimeLimitInHours(int limit) {
		this.timeLimitInHours = limit;
	}
	
	public boolean isExpired(Inspection inspection) {
		Date now = new Date();
		if ((inspection.getInspectionTime().getTime() - now.getTime()) < (timeLimitInHours * 60 * 60 * 1000)) {
			return true;
		}
		return false;
	}
}
